import { combineReducers } from 'redux';
import { LOGIN } from '@/actions/ActionTypes'

const initialAuthState = { 
    isLoggedIn: false,
    name: 'wangjiang from redux'
 };

function auth(state = initialAuthState, action) {
  switch (action.type) {
    case LOGIN.LOGIN_SUCCESS:
      return { ...state, isLoggedIn: true, token: action.user };
    case LOGIN.LOGIN_ERROR:
      return { ...state, isLoggedIn: false };
    default:
      return state;
  }
}

const AppReducer = combineReducers({
  auth
});

export default AppReducer;